//
//  DeferredLightingView.h
//  DeferredLighting
//
//  Created by Holmes Futrell on 2/8/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import <Cocoa/Cocoa.h>

#import "platform.h"
#import "ShaderProgram.h"
#import "IndexedModel.h"
#import "GLTexture.h"
#import "GLFont.h"

#import "matrix.h"
#import "matrix_helpers.h"
#import "vector.h"

#import "SimpleCompute.h"
#import "ComputeProgram.h"

#import <OpenCL/OpenCL.h>
#import "clb_error.h"

#import "ParticleSystem.h"

#include <sys/time.h>

@interface DeferredLightingView : NSOpenGLView {
	
	ComputeProgram *computeProgram;
	ComputeProgram *perBlockAttributesProgram;
	
	
	SimpleCompute *simpleCompute;
	
	ShaderProgram *tangentShader;
	ShaderProgram *basicShader;
	ShaderProgram *blitShader;	
	ShaderProgram *visualizeColor;	

	ShaderProgram *lightBufferShader;
	
	ShaderProgram *simpleGenLightbufferShader;
	
	IndexedModel *model1, *model2;
	GLTexture *texture, *normals;
		
	GLFont *font;
	
	int count;
	int fps;
	
	GLuint viewportWidth, viewportHeight;
	
	GLuint fbo;
	
	float rot;
	
	GLuint colorTextureID;
	
	// g-fbuffer
	GLuint depthTextureID;
	GLuint depthTexturePrimeID; // blitted from original :(
	GLuint normalTextureID;
	
	// light buffer
	GLuint lightbufferDiffuseTextureID;
	GLuint lightbufferSpecularTextureID;
	
	cl_mem diffuseImage, specularImage, normSpecImage, depthImage;
	cl_sampler nearestSampler;
	
	int num_per_block_attributes;
	cl_mem per_block_image1, per_block_image2;
	cl_int block_size[2];
	cl_int num_blocks[2];
	
#pragma mark -
	ComputeProgram *binningProgram;
	cl_int tile_size[2];
	cl_mem lightBins;
	cl_mem binCounts;
	int threadsPerTile;
#pragma mark -
	
	float zNear;
	float zFar;
	
	int finalBlitMode;
	
	float fovyInDegrees;
	float right, left, top, bottom;
	float aspect;
	
	ParticleSystem *particleSystem;
	
	struct timeval lastTime;
	
}

- (void)drawHUD;

@end
